class Person(object):
    def __init__(self, name, age, height, weight, money):

        self.name = name
        self.age = age
        self.height = height
        self.weight = weight
        self.__money = money
    @property
    def money(self):
        return self.__money
    @money.setter
    def money(self, value):
        if value < 0:
            self.__money = 0
        else:
            self.__money = value

    # def getMoney(self):
    #     return self.__money
    #
    # def setMoney(self, money):
    #     if money < 0:
    #         self.__money = 0
    #     else:
    #         self.__money = money

    def __del__(self):
        print("object delete")

    def say(self):
        return "my name is %s,I am %d years old"%(self.name, self.age)


per1 = Person("lifeibiao", 10, 20, 60, 100)

# print(per1.getMoney())
# per1.setMoney(10)
# print(per1.getMoney())

print(per1.age)
per1.age = 30
print(per1.age)

print("------------")
# 想让访问私有属性的方式类似访问普通属性,需要使用@property
# 让私有属性可以使用.语法
print(per1.money) # 相当于执行mongy()方法
per1.money = 10
print(per1.money)


